* {
    padding: 0;
    margin: 0;
}
.box1 {
    width: 150px;
    height: 120px;
    border: 1px solid #f00;
}
.box2 {
    width: 150px;
    height: 100px;
    border: 1px solid #f00;
}
.box3 {
    width: 150px;
    height: 40px;
    border: 1px solid #f00;
}
.box4 {
    width: 150px;
    height: 200px;
    border: 1px solid rgb(84,20,255);
}
[class^='box'] {
    /*margin: 20px;*/
    box-sizing: border-box;
    margin-top: 20px;
}

.wrap {
    padding: 0 20px;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    display: -webkit-flex;          /*  chrome and safari   */
    -webkit-flex-wrap: wrap;
    -webkit-justify-content: space-between;
}

@media (min-width: 641px) {
    .wrap {
        align-items: center;
        -webkit-align-items: center;
    }
}
@media (max-width: 640px) {
    .wrap {
        align-items: flex-start;
        -webkit-align-items: flex-start;
    }
    .box4 {
        order: -1;
        -webkit-order: -1;
    }
}
